<%@ page language="java" contentType="text/html; charset=UTF-8"
         pageEncoding="UTF-8" %>
<%
    String path = request.getContextPath();
    String basePath = request.getScheme() + "://"
            + request.getServerName() + ":" + request.getServerPort()
            + path;
%>
<!DOCTYPE html>
<html>
<head>
    <meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
    <meta name="viewport" content="width=device-width,initial-scale=1,user-scalable=0">
    <title>招生报名登录</title>
    <jsp:include page="/WEB-INF/page/common/_header.jsp"></jsp:include>
</head>
<body ontouchstart>
<div id="mainBox">
    <div style="padding-top: 25%">
        <form id="submitForm" class="weui_cells weui_cells_form bd-t0 afterNone">
            <div class="page-hd">
                <div class="tcenter"><img class="circle" width="100" height="100" src="<%=basePath %>/images/yxt.png"/>
                </div>
                <div class="tcenter">培立实验小学招生报名登录</div>
            </div>
            <div class="weui_cell">
                <div class="weui_cell_hd tm"><label class="weui_label">账号</label></div>
                <div class="weui_cell_bd weui_cell_primary">
                    <input class="weui_input" id="userAccount" name="userAccount" type="number" pattern="[0-9]*"
                           placeholder="输入联系电话">
                </div>
            </div>
            <div class="weui_cell">
                <div class="weui_cell_hd tm"><label class="weui_label">密码</label></div>
                <div class="weui_cell_bd weui_cell_primary">
                    <input class="weui_input" id="userPassword" name="userPassword" type="password"
                           placeholder="请输入密码"/>
                </div>
            </div>
            <div class="weui_btn_area">
                <a href="javascript:" id="loginSubmit" class="weui_btn weui_btn_primary">登 录</a>
                <a href="<%=basePath %>/signup/studentReg">
                    <div class="tm p15 f18">没账号，去注册</div>
                </a>
            </div>
        </form>
    </div>
</div>
<script type="text/javascript">
    $(function () {
        if (!/Android|webOS|iPhone|iPod|BlackBerry/i.test(navigator.userAgent)) {
            $("#mainBox").attr("style", "width:450px;margin: 0 auto;")
        }
        sessionStorage.setItem("signupType", "${signUpType}");  //参数：newStudent | middleStudent
    });

    $("#loginSubmit").click(function () {
        if ($("#userAccount").val() == "") {
            $.toast("登录账号不能为空");
            return false;
        }
        if ($("#userPassword").val() == "") {
            $.toast("登录密码不能为空");
            return false;
        }
        $.ajax({
            url: basePath + "/signup/student/admin",
            type: 'POST',
            dataType: "json",
            data: $('#submitForm').serialize(), //序列化
            success: function (data) {
                if (data.code != "000") {
                    $("#userPassword").val(null);
                    $.toast(data.msg);	//提示框？？
                } else {
                    $.toast("恭喜您登录成功！");
                    var url = basePath + "/signup/" + sessionStorage.getItem("signupType") + "?v=" + new Date().getTime();
                    setTimeout("javascript:location.href='" + url + "'", 1000);
                }
            },
            error: function (data) {
                alert("系统异常,请联系管理员");
            }
        });
    })
</script>
</body>
</html>